import * as Api from "../../api/device";
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    toastImg: "../../images/toast-ok.png",
    order_number: "",
    device_positions: [
      // {
      //   position: "32",
      //   is_success: false,
      // },
      // {
      //   position: "34",
      //   is_success: false,
      // },
      // {
      //   position: "61",
      //   is_success: false,
      // },
      // {
      //   position: "02",
      //   is_success: false,
      // },
    ],
    success_num: 0,
    device_positions_str: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // this.setData({
    //   order_number: options.order_number,
    //   device_positions_str: this.data.device_positions
    //     .filter((item) => item.is_success)
    //     .map((item) => item.position)
    //     .join("、"),
    // });
    Api.getRentalDeviceInfo(options.order_number).then((res) => {
      this.setData({
        device_positions: res.device_positions,
        success_num: res.success_num,
        device_positions_str: res.device_positions
          .filter((item) => !item.is_success)
          .map((item) => item.position)
          .join("、"),
      });
    });
  },
  /**
   * @description: 跳转页面
   * @return {*}
   */
  goToPages(e) {
    let url = e.currentTarget.dataset.url;
    if (url) {
      wx.navigateTo({ url });
    }
  },
});
